package cn.openea.perpartner.meily.web.entity.dto;

import cn.openea.perpartner.common.core.annotation.Excel;
import cn.openea.perpartner.meily.web.entity.RevenueRecordsArc;
import cn.openea.perpartner.meily.web.entity.RevenueRecordsIns;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.function.Function;

/**
 * @author ysk
 * @version 1.0.1
 * @createTime 2023年03月22日 16:50:00
 */
@Component
@Slf4j
public class RevenueRecordsDTOFactory {


    /**
     * 收益记录返回前端的数据
     */
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @SuperBuilder
    public static class RevenueRecordsDTO {

        private String id;
        /**
         * 创建时间
         */
        private String createTime;
        /**
         * 更新时间
         */
        private String updateTime;
        /**
         * 服务商userid
         */
        private String userId;
        /**
         * 服务商昵称
         */
        @Excel(name = "服务商昵称")
        private String nickName;
        /**
         * 编号
         */
        @Excel(name = "编号")
        private String providerId;
        /**
         * 所在地区
         */
        @Excel(name = "所在地区")
        private String area;
        /**
         * 所在街道
         */
        @Excel(name = "所在街道")
        private String street;
        /**
         * 地址
         */
        @Excel(name = "地址")
        private String address;
        /**
         * 店铺名称
         */
        @Excel(name = "店铺名称")
        private String storeName;
        /**
         * 手机号码
         */
        @Excel(name = "手机号码")
        private String phone;
        /**
         * 订单量
         */
        @Excel(name = "订单量")
        private String orderQuantity;
        /**
         * 商品量
         */
        @Excel(name = "商品量", cellType = Excel.ColumnType.NUMERIC)
        private String goodsQuantity;
        /**
         * 累计收益
         */
        @Excel(name = "累计收益", cellType = Excel.ColumnType.NUMERIC)
        private String accumulatedIncome;
        /**
         * 结算日期
         */
        @Excel(name = "结算日期", dateFormat = "yyyy-MM-dd")
        private String settlementDate;
        /**
         * 订单交易日期
         */
        @Excel(name = "订单交易日期", dateFormat = "yyyy-MM-dd")
        private String transactionDate;
        /**
         * 绑定公众号（是/否）
         */
        @Excel(name = "绑定公众号")
        private String bindOfficialAccount;
        /**
         * 状态。
         */
        private String status;
    }

    public Function<RevenueRecordsArc, RevenueRecordsDTO> revenueRecordsArcToDto = (revenueRecordsArc) -> RevenueRecordsDTO.builder()
            .id(revenueRecordsArc.getId())
            .createTime(revenueRecordsArc.getCreateTime())
            .updateTime(revenueRecordsArc.getUpdateTime())
            .userId(revenueRecordsArc.getUserId())
            .nickName(revenueRecordsArc.getNickName())
            .providerId(revenueRecordsArc.getProviderId())
            .area(revenueRecordsArc.getArea())
            .street(revenueRecordsArc.getStreet())
            .address(revenueRecordsArc.getAddress())
            .storeName(revenueRecordsArc.getStoreName())
            .phone(revenueRecordsArc.getPhone())
            .orderQuantity(revenueRecordsArc.getOrderQuantity())
            .goodsQuantity(revenueRecordsArc.getGoodsQuantity())
            .accumulatedIncome(revenueRecordsArc.getAccumulatedIncome())
            .settlementDate(revenueRecordsArc.getSettlementDate())
            .transactionDate(revenueRecordsArc.getTransactionDate())
            .bindOfficialAccount(revenueRecordsArc.getBindOfficialAccount())
            .status(revenueRecordsArc.getStatus())
            .build();


    public Function<RevenueRecordsIns, RevenueRecordsDTO> revenueRecordsInsToDto = (revenueRecordsIns) -> RevenueRecordsDTO.builder()
            .id(revenueRecordsIns.getId())
            .createTime(revenueRecordsIns.getCreateTime())
            .updateTime(revenueRecordsIns.getUpdateTime())
            .userId(revenueRecordsIns.getUserId())
            .nickName(revenueRecordsIns.getNickName())
            .providerId(revenueRecordsIns.getProviderId())
            .area(revenueRecordsIns.getArea())
            .street(revenueRecordsIns.getStreet())
            .address(revenueRecordsIns.getAddress())
            .storeName(revenueRecordsIns.getStoreName())
            .phone(revenueRecordsIns.getPhone())
            .orderQuantity(revenueRecordsIns.getOrderQuantity())
            .goodsQuantity(revenueRecordsIns.getGoodsQuantity())
            .accumulatedIncome(revenueRecordsIns.getAccumulatedIncome())
            .settlementDate(revenueRecordsIns.getSettlementDate())
            .transactionDate(revenueRecordsIns.getTransactionDate())
            .bindOfficialAccount(revenueRecordsIns.getBindOfficialAccount())
            .status(revenueRecordsIns.getStatus())
            .build();

}
